<template>
  <view>
    <block v-if="IFMY">
      <view :style="'--color:' + color + ';--rgbcolor:' + rgbcolor + ';'" class="detail_BN">
        <image :src="D.banner" mode="widthFix"></image>
        <view class="photo_s" @tap="my_infoFn">
          <image :src="D.cook_tg_photo_s" class="m" mode="aspectFill"></image>
          <view class="em">
            <view class="h4">
              {{ D.cook_tg_nickname }}
              <text class="id ico">
                （ID:{{ D.cook_tg_id }}）
                <text></text>
              </text>
            </view>
            <view class="gradeico">
              <image :src="D.cook_tg_grade_ico" mode="aspectFit"></image>
              <text class="span">{{ D.cook_tg_grade_title }}</text>
            </view>
          </view>
        </view>
      </view>
      <view :style="'--color:' + color + ';--rgbcolor:' + rgbcolor + ';'" class="navT">
        <view class="ul">
          <navigator v-if="D.iftx == 1" class="li" hoverClass="none" url="my_money?currentTab=mx&t=sy">
            <view class="dd">累计收益</view>
            <view class="dt">
              <view class="b">
                <text class="font">￥</text>
                {{ D.tgallmoney }}
              </view>
            </view>
          </navigator>
          <navigator v-if="D.iftx == 1" class="li" hoverClass="none" url="my_money?currentTab=mx&t=tx">
            <view class="dd">累计提现</view>
            <view class="dt">
              <view class="b">
                <text class="font">￥</text>
                {{ D.txallmoney }}
              </view>
            </view>
          </navigator>
          <navigator class="li" hoverClass="none" url="my_money">
            <view class="dd">账户余额</view>
            <view class="dt">
              <view class="b">
                <text class="font">￥</text>
                {{ D.money }}
              </view>
            </view>
          </navigator>
        </view>
        <view class="btn5 ico" @tap="tghbFn">立即推广</view>
      </view>
      <view :style="'--color:' + color + ';--rgbcolor:' + rgbcolor + ';'" class="col2">
        <navigator hoverClass="none" url="/hnPages/tg/tgu?t=list1">
          <view class="h2">
            名下单身团
            <text class="ico"></text>
          </view>
          <view class="h6">我推荐的单身用户</view>
          <view class="div vip">{{ D.mxdst }}人</view>
          <view class="em ico"></view>
        </navigator>
        <navigator hoverClass="none" url="/hnPages/tg/tgtd?t=list1">
          <view class="h2">
            名下合伙人
            <text class="ico"></text>
          </view>
          <view class="h6">我推荐的推广员</view>
          <view class="div vip2">{{ D.mxhhr }}人</view>
          <view class="em ico"></view>
        </navigator>
      </view>
      <view class="menu_my">
        <view class="ul">
          <view class="li" @tap="broker">
            <text class="i alyIcon-jingjiren jjr"></text>
            <text class="h4">情感导师</text>
          </view>
          <view class="li" @tap="vipFn">
            <text class="i ico vip"></text>
            <text class="h4">推广升级</text>
            <text class="span">多重奖励机制，收益翻翻</text>
          </view>
          <navigator v-if="D.ifxqk == 1" class="li" hoverClass="none" url="xqk_ulist">
            <text class="i ico xqk"></text>
            <text class="h4">相亲卡片</text>
            <text class="span">分享相亲卡拿奖励</text>
          </navigator>
          <navigator class="li" hoverClass="none" openType="redirect" url="msg">
            <text class="i ico xttz"></text>
            <text class="h4">消息通知</text>
          </navigator>
          <navigator class="li" hoverClass="none" url="my_info">
            <text class="i ico account"></text>
            <text class="h4">账户/认证</text>
          </navigator>
          <block v-if="D.iftx == 1">
            <navigator class="li" hoverClass="none" url="my_money?currentTab=mx&t=sy">
              <text class="i ico symx"></text>
              <text class="h4">收益明细</text>
            </navigator>
            <navigator class="li" hoverClass="none" url="my_money?currentTab=tx">
              <text class="i ico wytx"></text>
              <text class="h4">我要提现</text>
            </navigator>
            <navigator class="li" hoverClass="none" url="my_money?currentTab=mx&t=tx">
              <text class="i ico txjl"></text>
              <text class="h4">提现记录</text>
            </navigator>
          </block>
        </view>
      </view>
      <view v-if="div_myinfo_form" class="mask2 alpha0_100">
        <view class="div_box big_normal div_myinfo_box" style="--div_box_width: 82%; --div_box_height: 550rpx">
          <view class="close ico" @tap="my_info_closeFn"></view>
          <view class="div_title">修改信息</view>
          <form class="myinfo" @submit="myinfo_form_submitFn">
            <view class="dl">
              <view class="dt">头像</view>
              <view class="dd photo_sbtn" @tap="my_info_photo_s_addFn">
                <text v-if="globalUtils.empty(D.cook_tg_photo_s)" class="photo_tips ico">点击上传头像</text>
                <image v-else :src="D.cook_tg_photo_s" mode="aspectFill"></image>
                <input :value="D.cook_tg_photo_s_dbname" name="photo_s"/>
              </view>
            </view>
            <view class="dl">
              <view class="dt">昵称</view>
              <view class="dd">
                <input :value="D.cook_tg_nickname" autocomplete="off" class="input" maxlength="30" name="nickname"
                       placeholder="输入网名昵称"/>
              </view>
            </view>
            <view class="dl">
              <view class="dt">微信</view>
              <view class="dd">
                <input :value="D.cook_tg_weixin" autocomplete="off" class="input" maxlength="50" name="weixin"
                       placeholder="输入微信手机"/>
              </view>
            </view>
            <view class="dl">
              <view class="dt">简介</view>
              <view class="dd">
                <input :value="D.content" autocomplete="off" class="input" maxlength="50" name="content"
                       placeholder="输入您的简介"/>
              </view>
            </view>
            <button :style="'--color:' + color + ';--rgbcolor:' + rgbcolor + ';'" class="btn4 ico" formType="submit">
              保存
            </button>
          </form>
        </view>
      </view>
      <view class="blank"></view>
      <!-- parse <include src="TG_btm_nav.wxml"></include> -->
      <block>
        <view
            :style="'--color:' + color + ';--rgbcolor:' + rgbcolor + ';--btmnavbg_color:' + btmnavbg_color + ';--btmnavbg_rgbcolor:' + btmnavbg_rgbcolor + ';'"
            class="btm_nav"
        >
          <view class="shadow"></view>
          <view class="navabox">
            <navigator :class="'a ' + (btm_nav == 'index' ? ' ed' : '')"
                       :url="'index?tguid=' + tguid + '&admid=' + admid" hoverClass="none"
                       openType="redirect">
              <view class="i">
                <view class="image ico"></view>
              </view>
              <view class="font">首页</view>
            </navigator>
            <navigator :class="'a ' + (btm_nav == 'help' ? ' ed' : '')" :url="'help?tguid=' + tguid + '&admid=' + admid"
                       hoverClass="none"
                       openType="redirect">
              <view class="i">
                <view class="image ico"></view>
              </view>
              <view class="font">帮助</view>
            </navigator>
            <navigator :class="'a ' + (btm_nav == 'msg' ? ' ed' : '')" :url="'msg?tguid=' + tguid + '&admid=' + admid"
                       hoverClass="none"
                       openType="redirect">
              <view class="i">
                <view class="image ico"></view>
                <text v-if="btm_nav_msg_num > 0" class="span">{{ btm_nav_msg_num }}</text>
              </view>
              <view class="font">通知</view>
            </navigator>
            <navigator :class="'a ' + (btm_nav == 'my' ? ' ed' : '')" :url="'my?tguid=' + tguid + '&admid=' + admid"
                       hoverClass="none"
                       openType="redirect">
              <view class="i">
                <view class="image ico"></view>
              </view>
              <view class="font">我的</view>
            </navigator>
          </view>
        </view>
        <view v-if="backtop_flag" :style="'color:' + color" class="backtop fadeInUp" data-id="index" @tap="backtopFn">
          <text class="ico icon-backtop"></text>
          顶部
        </view>
      </block>
    </block>
  </view>
</template>
<script>
import globalUtils from "../../res/www.a9a.cn";

var t;
var a = require('../../@babel/runtime/helpers/defineProperty');
var i = require('../../res/www.a9a.cn.js');
var app = getApp();
export default {
  computed: {
    globalUtils() {
      return globalUtils
    }
  },
  data() {
    return {
      IFMY: false,
      nTitle: '我的推广中心',
      btm_nav: 'my',
      btmnavbg_color: '#B8BCCC',
      btmnavbg_rgbcolor: i.c16_rgb('#B8BCCC'),
      mask_class: 'alpha0_100',
      div_myinfo_form: false,
      color: '',
      rgbcolor: '',
      tguid: '',
      admid: '',
      D: {
        banner: '',
        cook_tg_photo_s: '',
        cook_tg_grade_ico: '',
        cook_tg_grade_title: '',
        iftx: 0,
        mxdst: '',
        mxhhr: '',
        ifxqk: 0,
        cook_tg_photo_s_dbname: '',
        cook_tg_nickname: '',
        cook_tg_weixin: ''
      },

      MB: '',
      btm_nav_msg_num: '',
      div_login: false,
      div_outlist_box_class: '',
      photo_s: '',
      backtop_flag: 0
    };
  },
  onLoad: function (t) {
    var that = this;
    var n = this;
    var e = 0;
    var s = 0;
    app.globalData.get_config('_ZEAI').then(function (t) {
      n.setData({
        color: app.globalData._ZEAI.color,
        rgbcolor: i.c16_rgb(app.globalData._ZEAI.color)
      });
    });
    if (i.ifint(t.tguid) || i.ifint(t.admid)) {
      e = i.ifint(t.tguid) ? t.tguid : 0;
      s = i.ifint(t.admid) ? t.admid : 0;

    }
    n.setData({
      tguid: e,
      admid: s
    });
    console.log('这是推广ID吗', that.tguid)
    console.log('这是什么ID', that.admid)
    app.globalData.get_openid().then(function (t) {
      that.init();
    });
  },
  onPullDownRefresh: function () {
    var that = this;
    uni.vibrateShort({
      type: 'heavy'
    });
    setTimeout(function () {
      uni.stopPullDownRefresh();
      that.init();
    }, 500);
  },
  onShareAppMessage: function (t) {
    return {
      imageUrl: this.SHARE.imgurl,
      title: this.SHARE.title,
      path: '/pages/tg/my'
    };
  },
  onShareTimeline: function () {
    return {
      imageUrl: this.SHARE.imgurl,
      title: this.SHARE.title,
      query: '',
      path: '/pages/tg/my'
    };
  },
  methods: {
    init: function () {
      var that = this;
      uni.showNavigationBarLoading();
      t = uni.getStorageSync('COOK_U');
      app.globalData.ajax({
        url: 'tg.php',
        data: {
          submitok: 'MY',
          openid: t.openid,
          tguid: that.tguid,
          admid: that.admid
        },
        success: function (t) {
          console.log('这是什么值', t);
          switch ((uni.hideNavigationBarLoading(), t.flag)) {
            case '1':
            case 1:
              var o = t.D.color;
              that.setData({
                IFMY: true,
                nTitle: t.nTitle,
                D: t.D,
                MB: t.MB,
                btm_nav_msg_num: t.btm_nav_msg_num
              });
              uni.setNavigationBarColor({
                backgroundColor: o,
                frontColor: '#ffffff'
              });
              uni.setNavigationBarTitle({
                title: t.nTitle
              });
              uni.setBackgroundColor({
                backgroundColorTop: o
              });
              break;
            case 'flag0':
            case 'flag_1':
            case 'flag2':
              uni.redirectTo({
                url: '/hnPages/tg/reg?t=' + t.flag
              });
              console.log('跳转页面', t.flag)
              break;
            default:
              t.this = that;
              t.url = 'no';
              i.sorry(t);
          }
        }
      });
    },

    back: function () {
      this.setData({
        div_login: false
      });
    },

    copywxFn: function (t) {
      i.copy_text({
        data: this.OUT.weixin,
        msg: '复制成功'
      });
    },

    mask_closeFn: function (t) {
      var that = this;
      var o = t.currentTarget.dataset.maskid;
      this.setData({
        mask_class: 'alpha100_0',
        div_outlist_box_class: 'div_upAnm2'
      });
      setTimeout(function () {
        var t;
        that.setData((a((t = {}), o, false), a(t, 'mask_class', 'alpha0_100'), a(t, 'div_outlist_box_class', 'div_upAnm1'), t));
      }, 500);
    },
    broker: function () {
      uni.navigateTo({
        url: '/hnPages/tg/broker/broker'
      });
    },
    vipFn: function () {
      i.empty(this.MB) || app.globalData.openSetting(this.MB);
      uni.navigateTo({
        url: '/hnPages/tg/my_vip'
      });
    },

    my_infoFn: function () {
      this.setData({
        div_myinfo_form: true
      });
    },

    my_info_closeFn: function () {
      this.setData({
        div_myinfo_form: false
      });
    },

    my_info_photo_s_addFn: function () {
      var that = this;
      uni.chooseMedia({
        count: 1,
        mediaType: ['image'],
        sourceType: ['album', 'camera'],
        sizeType: ['compressed'],
        success: function (e) {
          that.setData({
            photo_s: e.tempFiles[0].tempFilePath
          });
          uni.uploadFile({
            url: app.globalData.WWW + '/api/wxxcx/tg.php',
            filePath: e.tempFiles[0].tempFilePath,
            name: 'pic',
            formData: {
              submitok: 'myinfo_photo_s_up',
              openid: t.openid
            },
            success: function (t) {
              var o;
              1 == (t = i.jsoneval(t.data)).flag
                  ? that.setData((a((o = {}), 'D.cook_tg_photo_s', t.cook_tg_photo_s), a(o, 'photo_s_dbname', t.dbname), o))
                  : uni.showModal({
                    content: t.msg,
                    confirmColor: that.color,
                    confirmText: '朕知道了',
                    showCancel: false,
                    success: function (t) {
                    }
                  });
            }
          });
        }
      });
    },

    myinfo_form_submitFn: function (a) {
      var that = this;
      var e = a.detail.value;
      app.globalData.ifweixin(e.weixin)
          ? app.globalData.empty(e.nickname)
              ? uni.showToast({
                title: '请输入【网名昵称】',
                icon: 'none',
                mask: true
              })
              : app.globalData.ajax({
                url: 'tg.php',
                data: {
                  submitok: 'myinfo_modupdate',
                  openid: t.openid,
                  weixin: e.weixin,
                  nickname: e.nickname,
                  photo_s: e.photo_s,
                  content: e.content
                },
                success: function (t) {
                  uni.hideLoading();
                  1 == t.flag
                      ? (that.setData({
                        div_myinfo_form: false
                      }),
                          uni.startPullDownRefresh())
                      : ((t.this = that), (t.url = 'no'), i.sorry(t));
                }
              })
          : uni.showToast({
            title: '请输入【微信或手机】',
            icon: 'none',
            mask: true
          });
    },

    tghbFn: function () {
      i.empty(this.MB) || app.globalData.openSetting(this.MB);
      uni.navigateTo({
        url: '/hnPages/tg/my_ewm?tguid=' + this.D.cook_tg_id
      });
    },

    backtopFn() {
      console.log('占位：函数 backtopFn 未声明');
    }
  }
};
</script>
<style>
@import 'my.css';
</style>
